#include <bits/stdc++.h>
using namespace std;
int T;
void solve()
{
    int n,m,L,V;
    int d[100005],v[100005],a[100005],p[100005];
    cin >> n >> m >> L >> V;
    for(int i=1; i<=n; i++)
        cin >> d[i] >> v[i] >> a[i];
    int ans=0;
    for(int i=1; i<=m; i++)
        cin >> p[i];
    sort(p+1,p+m+1);
    for(int i=n ;i>=1; i--)
    {
        if(p[m]>=d[i] && v[i]>V)
            ans++;
    }
    cout << ans << ' ' << 1 << endl;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> T;
    while(T--) solve();
    return 0;
}
